<template>
  <div>
    <el-table :data="tableData">
      <el-table-column label="名称" prop="summary"></el-table-column>

      <el-table-column>
        <template slot-scope="scope">
          <div>
            <el-button @click="onExecInstance(scope.row)" type="text">执行</el-button>
          </div>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { defineComponent, reactive, ref } from "@vue/composition-api";
import { createInstance, fetchInstancePage } from "@/api/api";
import { useApiStore } from "@/store/api";
export default defineComponent({
  setup(props, { emit }) {
    const apiStore = useApiStore()

    const tableData = ref([]);
    const total = ref(0)
    const querySearch = reactive({
        page: 1,
        pageSize: 10,
    })


    function fetchData() {
        fetchInstancePage({
            docId: apiStore.docId,
            projectId: apiStore.projectId,
            ...querySearch
        }).then(res => {
            tableData.value = res.data.list
            total.value = res.data.total
        })
    }
    fetchData()

    function onExecInstance(row) {
        emit('exec', row)
    }

    return {
      tableData,
      onExecInstance,
      total
    };
  },
});
</script>

<style scoped>
</style>